//
//  RootViewController.m
//  Meiqi
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "RootViewController.h"
#import "BaseViewController.h"
#import "MqInformationViewController.h"
#import "MqForumViewController.h"
#import "MqProductViewController.h"
#import "MqSingleton.h"
#import "PKLoginViewController.h"
#import <CoreLocation/CoreLocation.h>
#import <BaiduMapAPI_Location/BMKLocationComponent.h>
@interface RootViewController () 


@end

@implementation RootViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tabBar.tintColor = [UIColor redColor];
    
    [self addViewControllerClass:[MqInformationViewController class] title:@"资讯" imageName:@"iconfont-zhuye1" selectImage:@"iconfont-zhuye2"];
    
    [self addViewControllerClass:[MqForumViewController class] title:@"论坛" imageName:@"community" selectImage:@"community_selected@2x"];
    
    [self addViewControllerClass:[MqProductViewController class] title:@"找车" imageName:@"zixingche1" selectImage:@"zixingche2"];
    
    [self addViewControllerClass:[PKLoginViewController class] title:@"我的" imageName:@"mine@2x" selectImage:@"mine_selected@2x"];
   
//    [self isLocation];
    
    //  启用定位服务
    [MqSingleton shareData];
   
}

//  添加视图控制器
- (void)addViewControllerClass:(Class)class title:(NSString *)title imageName:(NSString *)imageName selectImage:(NSString *)selectImageName
{
    BaseViewController *viewC = [[class alloc] init];
    UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:viewC];
    navc.tabBarItem.title = title;
    navc.tabBarItem.image = [UIImage imageNamed:imageName];
    navc.tabBarItem.selectedImage = [[UIImage imageNamed:selectImageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    navc.navigationBar.hidden = YES;
    [self addChildViewController:navc];
    
    
}





////  获取位置信息
//- (void)getLocation
//{
//    [self.locationManager requestLocation];
//}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
{
    CLLocation *location = [locations firstObject];
    
    [MqSingleton shareData].lon = location.coordinate.longitude;
    [MqSingleton shareData].lat = location.coordinate.latitude;
   
//    [MqSingleton shareData].lon = ;
//    [MqSingleton shareData].lat = ;
    
    NSLog(@"%f  --  %f", [MqSingleton shareData].lon, [MqSingleton shareData].lat);
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
